package cn.gailvlun.gll.util;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;

import java.nio.charset.Charset;

import cn.gailvlun.gll.widget.dialog.ProgressDialog;



public class DialogUtil {

    public static Dialog showIndeterminate(Context context) {
        ProgressDialog pd = new ProgressDialog(context);
        pd.show();
        return pd;
    }

    public static MaterialDialog showError(Context context, CharSequence content) {
        return new MaterialDialog.Builder(context)
                .title("错误")
                .content(content)
                .show();
    }

    public static MaterialDialog showError(Context context, CharSequence content, MaterialDialog.SingleButtonCallback callback) {
        return new MaterialDialog.Builder(context)
                .title("错误")
                .content(content)
                .positiveText("确定")
                .onPositive(callback)
                .show();
    }

    public static MaterialDialog showHint(Context context, CharSequence content) {
        return new MaterialDialog.Builder(context)
                .title("提示")
                .content(content)
                .positiveText("确定")
                .show();
    }

    public static MaterialDialog showHint(Context context, CharSequence content, MaterialDialog.SingleButtonCallback callback) {
        return new MaterialDialog.Builder(context)
                .title("提示")
                .content(content)
                .positiveText("确定")
                .onPositive(callback)
                .show();
    }

    public static MaterialDialog showHint(Context context, CharSequence content, String posText,
                                          String negText, MaterialDialog.SingleButtonCallback callback) {
        return new MaterialDialog.Builder(context)
                .title("提示")
                .content(content)
                .positiveText(posText)
                .negativeText(negText)
                .onAny(callback)
                .show();
    }

    public static MaterialDialog showWarning(Context context, CharSequence content, MaterialDialog.SingleButtonCallback callback) {
        return new MaterialDialog.Builder(context)
                .title("警告")
                .content(content)
                .positiveText("确定")
                .negativeText("取消")
                .onAny(callback)
                .show();
    }

}
